﻿Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports BBDD
Imports Controladores

 _

Class index
    Inherits System.Web.UI.Page


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If Not (Session("privUser") Is Nothing) Then
            Select Case Integer.Parse(Session("privUser").ToString())
                Case 1
                    Response.Redirect("user.aspx")
                Case 2
                    Response.Redirect("oper.aspx")
                Case 3
                    Response.Redirect("admin.aspx")
            End Select
        End If
    End Sub 'Page_Load

    Protected Sub boton_loguearse_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim DNIInput As String = campoDNI.Text
        Dim err As String = controlador.login(DNIInput, campoPass.Text)
        If err.Equals("") Then

            Session("DNIUser") = DNIInput
            Session("privUser") = Consultas.getprivilegios(DNIInput)
            Select Case Integer.Parse(Session("privUser").ToString())
                Case 1
                    Response.Redirect("user.aspx")
                Case 2
                    Response.Redirect("oper.aspx")
                Case 3
                    Response.Redirect("admin.aspx")
            End Select

        Else
            controlador.CreateMessageAlert(Me, err, "")
        End If
    End Sub 'boton_loguearse_Click
End Class 'index